package group.hhsw.purchase.service.impl;

import group.hhsw.common.model.vo.DetailOrder;
import group.hhsw.common.model.params.Check;
import group.hhsw.feign.clients.ProductClient;
import group.hhsw.feign.clients.UserClient;
import group.hhsw.purchase.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("2")
public class CheckAreaService implements PurchaseService {
    @Autowired
    private ProductClient productClient;

    @Autowired
    private UserClient userClient;

    @Override
    public DetailOrder atomicService(Check check) {
        DetailOrder detailOrder = new DetailOrder();
        String userArea = userClient.getArea(check.getUserId());
        String productArea = productClient.getArea(check.getProductId());
        detailOrder.setAreaIsOk(userArea.equals(productArea));
        return detailOrder;
    }

}
